<!DOCTYPE html>
<html >
<head>

    <!--[if lt IE 9]>
        <style>body {display: none; background: none !important} </style>
        <meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
    <![endif]-->

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<meta name="author" content="Mark" />



<meta name="description" content="C++回调函数必须为静态函数的原因。以及静态函数调用非静态成员的方法。

转自http://blog.csdn.net/u012072012/article/details/45537387">
<meta property="og:type" content="article">
<meta property="og:title" content="Cpp中回调函数与静态成员">
<meta property="og:url" content="http://markma.tk/posts/QtStudy/Cpp中回调函数与静态成员/index.html">
<meta property="og:site_name" content="Mark's Blog">
<meta property="og:description" content="C++回调函数必须为静态函数的原因。以及静态函数调用非静态成员的方法。

转自http://blog.csdn.net/u012072012/article/details/45537387">
<meta property="og:updated_time" content="2017-04-21T07:50:37.065Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Cpp中回调函数与静态成员">
<meta name="twitter:description" content="C++回调函数必须为静态函数的原因。以及静态函数调用非静态成员的方法。

转自http://blog.csdn.net/u012072012/article/details/45537387">

<link rel="apple-touch-icon" href= "/apple-touch-icon.png">




    <link rel="shortcut icon" href="/favicon.png">



    <link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">



    <link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">



    <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
    <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">


<link rel="stylesheet" href="/css/style.css">



<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


<title>Cpp中回调函数与静态成员 | Mark&#39;s Blog</title>

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

<script>
    var yiliaConfig = {
        fancybox: true,
        animate: true,
        isHome: false,
        isPost: true,
        isArchive: false,
        isTag: false,
        isCategory: false,
        fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
        scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
        search: true
    }
</script>


    <script>
        yiliaConfig.jquery_ui = [true, "//cdn.bootcss.com/jqueryui/1.10.4/jquery-ui.min.js", "//cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css"];
    </script>



    <script> yiliaConfig.rootUrl = "\/";</script>





    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?fad5c01287c961d95e4fe533d91c8aab";
            var s = document.getElementsByTagName("script")[0]; 
            s.parentNode.insertBefore(hm, s);
        })();
    </script>


</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            <img src="/img/avatar.png" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">Mark</a></h1>
        </hgroup>

        
        <p class="header-subtitle">To do to make progress</p>
        

        
            <form id="search-form">
            <input type="text" id="local-search-input" name="q" placeholder="search..." class="search form-control" autocomplete="off" autocorrect="off" searchonload="false" />
            <i class="fa fa-times" onclick="resetSearch()"></i>
            </form>
            <div id="local-search-result"></div>
            <p class='no-result'>No results found <i class='fa fa-spinner fa-pulse'></i></p>
        


        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>Menu</li>
                        <li>Tags</li>
                        
                        <li>Friends</li>
                        
                        
                        <li>About Me</li>
                        
                    </ul>
                </div>
            </div>
        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">主页</a></li>
                        
                            <li><a href="/tags/">分类</a></li>
                        
                            <li><a href="/archives/">归档</a></li>
                        
                            <li><a href="/gallery/">相册</a></li>
                        
                            <li><a href="/about/">关于我</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" href="mailto:ma-mark@outlook.com" title="Email"></a>
                            
                                <a class="fa 新浪微博" href="http://weibo.com/mark900" title="新浪微博"></a>
                            
                                <a class="fa GitHub" href="https://github.com/markma" title="GitHub"></a>
                            
                                <a class="fa 知乎" href="https://www.zhihu.com/people/mark900" title="知乎"></a>
                            
                                <a class="fa Coding" href="https://coding.net/u/maxiaohang" title="Coding"></a>
                            
                                <a class="fa 网易云音乐" href="http://music.163.com/#/user/home?id=115229883" title="网易云音乐"></a>
                            
                                <a class="fa QQ" href="http://wpa.qq.com/msgrd?v=3&uin=954373276&site=qq&menu=yes" title="QQ"></a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Cpp/">Cpp</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Hexo/">Hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Journal/">Journal</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Matlab/">Matlab</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/OpenLibrary/">OpenLibrary</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Python/">Python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Qt/">Qt</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Robot/">Robot</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Wiki/">Wiki</a></li></ul>
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a class="main-nav-link switch-friends-link" href="http://moxfive.xyz/">MOxFIVE</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">因为爱好，做着自己本不该做的事。为爱而活，不受羁绊！</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">Mark</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                <img src="/img/avatar.png" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">Mark</a></h1>
            </hgroup>
            
            <p class="header-subtitle">To do to make progress</p>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">主页</a></li>
                
                    <li><a href="/tags/">分类</a></li>
                
                    <li><a href="/archives/">归档</a></li>
                
                    <li><a href="/gallery/">相册</a></li>
                
                    <li><a href="/about/">关于我</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" target="_blank" href="mailto:ma-mark@outlook.com" title="Email"></a>
                            
                                <a class="fa 新浪微博" target="_blank" href="http://weibo.com/mark900" title="新浪微博"></a>
                            
                                <a class="fa GitHub" target="_blank" href="https://github.com/markma" title="GitHub"></a>
                            
                                <a class="fa 知乎" target="_blank" href="https://www.zhihu.com/people/mark900" title="知乎"></a>
                            
                                <a class="fa Coding" target="_blank" href="https://coding.net/u/maxiaohang" title="Coding"></a>
                            
                                <a class="fa 网易云音乐" target="_blank" href="http://music.163.com/#/user/home?id=115229883" title="网易云音乐"></a>
                            
                                <a class="fa QQ" target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=954373276&site=qq&menu=yes" title="QQ"></a>
                            
                        </ul>
            </nav>
        </header>                
    </div>
    <link class="menu-list" tags="Tags" friends="Friends" about="About Me"/>
</nav>
      <div class="body-wrap"><article id="post-posts/QtStudy/Cpp中回调函数与静态成员" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/posts/QtStudy/Cpp中回调函数与静态成员/" class="article-date">
      <time datetime="2017-04-21T07:41:37.000Z" itemprop="datePublished">2017-04-21</time>
</a>


    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      Cpp中回调函数与静态成员
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/QtStudy/">QtStudy</a>
    </div>


        
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Cpp/">Cpp</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Qt/">Qt</a></li></ul>
    </div>

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <blockquote>
<p>C++回调函数必须为静态函数的原因。以及静态函数调用非静态成员的方法。</p>
</blockquote>
<p>转自<a href="http://blog.csdn.net/u012072012/article/details/45537387" title=" C++回调函数必须为静态函数的原因" target="_blank" rel="external">http://blog.csdn.net/u012072012/article/details/45537387</a><br><a id="more"></a></p>
<h2 id="回调函数简介"><a href="#回调函数简介" class="headerlink" title="回调函数简介"></a>回调函数简介</h2><p>一个对象的this指针并不是对象本身的一部分，不会影响sizeof(对象)的结果。this作用域是在类内部，当在类的非静态成员函数中访问类的非静态成员的时候，编译器会自动将对象本身的地址作为一个隐含参数传递给函数。也就是说，即使你没有写上this指针，编译器在编译的时候也是加上this的，它作为非静态成员函数的隐含形参，对各成员的访问均通过this进行。</p>
<p>为了实现回调，我们必须把this指针给转换掉！可为了在该函数中可以直接操作该类中的成员，我们必须保留this指针！所以这是矛盾的。<br>在类封装回调函数：<br> a.回调函数只能是全局的或是静态的。</p>
<p> b.全局函数会破坏类的封装性，故不予采用。</p>
<p> c.静态函数只能访问类的静态成员，不能访问类中非静态成员</p>
<p>让静态函数访问类的非静态成员的方法：<br>在消息回调的函数参数中传递一个该类的指针即可,就像类中创建一个多线程的回调一样.将类的指针传递给该回调函数,然后用该指针调用类的非静态成员函数和指针.或者用一个类的全局指针数组,保存每一个创建出来的类的this指针,用全局指针去调用。如下：<br> class A()<br>回调函数中访问非静态成员<br>  由于回调函数往往有固定定义，并不接受  A * pThis 参数<br>   如：CALLBACK MyTimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime);</p>
<h3 id="【解决方案1】：本方案当遇到有多个类实例对象时会有问题。原因是pThis指针只能指向一个对象。"><a href="#【解决方案1】：本方案当遇到有多个类实例对象时会有问题。原因是pThis指针只能指向一个对象。" class="headerlink" title="【解决方案1】：本方案当遇到有多个类实例对象时会有问题。原因是pThis指针只能指向一个对象。"></a>【解决方案1】：本方案当遇到有多个类实例对象时会有问题。原因是pThis指针只能指向一个对象。</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">class</span> <span class="title">A</span><span class="params">()</span></span></div><div class="line">&#123;</div><div class="line">      <span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">a</span><span class="params">()</span></span>; <span class="comment">//静态回调函数</span></div><div class="line"></div><div class="line">      <span class="function"><span class="keyword">void</span> <span class="title">b</span><span class="params">()</span></span>;  <span class="comment">//非静态函数 </span></div><div class="line"></div><div class="line">      <span class="keyword">static</span> A * pThis;   <span class="comment">//静态对象指针</span></div><div class="line">&#125;  </div><div class="line"></div><div class="line">A * A::pThis=<span class="literal">NULL</span>;</div><div class="line">A::A()   <span class="comment">//构造函数中将this指针赋给pThis，使得回调函数能通过pThis指针访问本对象</span></div><div class="line">&#123;</div><div class="line">       pThis=<span class="keyword">this</span>;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="keyword">void</span> A::a()</div><div class="line">&#123;</div><div class="line">      <span class="keyword">if</span> (pThis==<span class="literal">NULL</span>) <span class="keyword">return</span>;</div><div class="line">      pThis-&gt;b(); <span class="comment">//回调函数中调用非静态函数 </span></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="【解决方案2】：本方案解决多个类实例对象时方案1的问题。用映射表存所有对象地址，每个对象保存自己的ID号。"><a href="#【解决方案2】：本方案解决多个类实例对象时方案1的问题。用映射表存所有对象地址，每个对象保存自己的ID号。" class="headerlink" title="【解决方案2】：本方案解决多个类实例对象时方案1的问题。用映射表存所有对象地址，每个对象保存自己的ID号。"></a>【解决方案2】：本方案解决多个类实例对象时方案1的问题。用映射表存所有对象地址，每个对象保存自己的ID号。</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">typedef</span> CMap&lt;UINT,UINT,A*,A*&gt; CAMap;</div><div class="line"><span class="function"><span class="keyword">class</span> <span class="title">A</span><span class="params">()</span></span></div><div class="line">&#123;</div><div class="line">      <span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">a</span><span class="params">()</span></span>; <span class="comment">//静态回调函数</span></div><div class="line">      <span class="function"><span class="keyword">void</span> <span class="title">b</span><span class="params">()</span></span>;  <span class="comment">//非静态函数 </span></div><div class="line">      <span class="keyword">int</span> m_ID;  <span class="comment">//本对象在列表中的ID号</span></div><div class="line">      <span class="keyword">static</span> <span class="keyword">int</span> m_SID;   <span class="comment">//静态当前对象ID        (需要时，将m_ID赋值给m_SID以起到调用本对象函数的功能)</span></div><div class="line">      <span class="keyword">static</span> CAMap m_Map; <span class="comment">//静态对象映射表</span></div><div class="line">&#125;  </div><div class="line"></div><div class="line">CAMap A::m_Map;</div><div class="line"></div><div class="line"><span class="keyword">int</span>   A::m_SID=<span class="number">0</span>;</div><div class="line"></div><div class="line">  </div><div class="line"></div><div class="line"> </div><div class="line"></div><div class="line">A::A()   <span class="comment">//构造函数中将this指针赋给pThis，使得回调函数能通过pThis指针访问本对象</span></div><div class="line">&#123;</div><div class="line">      <span class="keyword">if</span>(m_Map.IsEmpty())</div><div class="line">      &#123;</div><div class="line">   			m_ID=<span class="number">1</span>;</div><div class="line">      &#125;</div><div class="line">      <span class="keyword">else</span></div><div class="line">      &#123; </div><div class="line">        m_ID=m_Map.GetCount()+<span class="number">1</span>;</div><div class="line">      &#125;</div><div class="line">      m_Map.SetAt( m_ID, <span class="keyword">this</span> );</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="keyword">void</span> A::a()</div><div class="line">&#123;</div><div class="line">      <span class="keyword">if</span> (m_Map.IsEmpty()) <span class="keyword">return</span>;</div><div class="line">      A * pThis=<span class="literal">NULL</span>;</div><div class="line">      <span class="keyword">if</span>(m_Map.Lookup(m_SID,pThis))</div><div class="line">      &#123;</div><div class="line">   		pThis-&gt;b(); <span class="comment">//回调函数中调用非静态函数 </span></div><div class="line">      &#125;;</div><div class="line">  &#125;</div></pre></td></tr></table></figure>
      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>Title:</span><a href="/posts/QtStudy/Cpp中回调函数与静态成员/">Cpp中回调函数与静态成员</a></p>
        <p><span>Author:</span><a href="/" title="Back to Homepage">Mark</a></p>
        <p><span>Created:</span>2017-04-21, 15:41:37</p>
        <p><span>Updated:</span>2017-04-21, 15:50:37</p>
        <p>
            <span>Full URL:</span><a class="post-url" href="/posts/QtStudy/Cpp中回调函数与静态成员/" title="Cpp中回调函数与静态成员">http://markma.tk/posts/QtStudy/Cpp中回调函数与静态成员/</a>
            <span class="copy-path" data-clipboard-text="From http://markma.tk/posts/QtStudy/Cpp中回调函数与静态成员/　　By Mark" title="Copy Article&#39;s Link &amp; Author"><i class="fa fa-clipboard"></i></span>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>License:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="CC BY-NC-SA 4.0 International" target = "_blank">"CC BY-NC-SA 4.0"</a> Keep Link &amp; Author if Distribute.
        </p>
    </div>



    <nav id="article-nav">
        
            <div id="article-nav-newer" class="article-nav-title">
                <a href="/posts/Matlab/matlab cpp混编/">
                    matlab cpp混编
                </a>
            </div>
        
        
            <div id="article-nav-older" class="article-nav-title">
                <a href="/posts/QtStudy/Qt中pro文件写法/">
                    Qt pro文件写法
                </a>
            </div>
        
    </nav>

  
</article>

    <div id="toc" class="toc-article">
        <strong class="toc-title">Contents</strong>
        
            <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#回调函数简介"><span class="toc-number">1.</span> <span class="toc-text">回调函数简介</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#【解决方案1】：本方案当遇到有多个类实例对象时会有问题。原因是pThis指针只能指向一个对象。"><span class="toc-number">1.1.</span> <span class="toc-text">【解决方案1】：本方案当遇到有多个类实例对象时会有问题。原因是pThis指针只能指向一个对象。</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#【解决方案2】：本方案解决多个类实例对象时方案1的问题。用映射表存所有对象地址，每个对象保存自己的ID号。"><span class="toc-number">1.2.</span> <span class="toc-text">【解决方案2】：本方案解决多个类实例对象时方案1的问题。用映射表存所有对象地址，每个对象保存自己的ID号。</span></a></li></ol></li></ol>
        
    </div>
    <style>
        .left-col .switch-btn,
        .left-col .switch-area {
            display: none;
        }
        .toc-level-3 i,
        .toc-level-3 ol {
            display: none !important;
        }
    </style>

    <input type="button" id="tocButton" value="Hide"  title="Show or Hide Table of Contents">

    <script>
        yiliaConfig.toc = ["Hide", "Show", !!"false"];
    </script>



    
<div class="share">
    
        <div class="bdsharebuttonbox">
            <a href="#" class="fa fa-twitter bds_twi" data-cmd="twi" title="分享到推特"></a>
            <a href="#" class="fa fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
            <a href="#" class="fa fa-qq bds_sqq" data-cmd="sqq" title="分享给 QQ 好友"></a>
            <a href="#" class="fa fa-files-o bds_copy" data-cmd="copy" title="复制网址"></a>
            <a href="#" class="fa fa fa-envelope-o bds_mail" data-cmd="mail" title="通过邮件分享"></a>
            <a href="#" class="fa fa-weixin bds_weixin" data-cmd="weixin" title="生成文章二维码"></a>
            <a href="#" class="fa fa-share-alt bds_more" data-cmd="more"></i></a>
        </div>
        <script>
            window._bd_share_config={
                "common":{"bdSnsKey":{},"bdText":"Cpp中回调函数与静态成员　| Mark's Blog　","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
        </script>
    

    
</div>







    
      <div class="duoshuo" id="comments">
    <div id="comment-box" ></div>
    <div class="ds-thread" id="ds-thread" data-thread-key="posts/QtStudy/Cpp中回调函数与静态成员/" data-title="Cpp中回调函数与静态成员" data-url="http://markma.tk/posts/QtStudy/Cpp中回调函数与静态成员/"></div>
    <script>
        var duoshuoQuery = {short_name:"markma"};
        var loadComment = function(){
            var d = document, s = d.createElement('script');
            s.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
            s.async = true; s.charset = 'UTF-8';
            (d.head || d.body).appendChild(s);
        }

        
    </script>
    
    <script> loadComment(); </script>

</div>
    




    <div class="scroll" id="post-nav-button">
        
            <a href="/posts/Matlab/matlab cpp混编/" title="Pre: matlab cpp混编">
                <i class="fa fa-angle-left"></i>
            </a>
        

        <a title="Mini Archives"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>

        
            <a href="/posts/QtStudy/Qt中pro文件写法/" title="Next: Qt pro文件写法">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>

    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/posts/Matlab/matlab cpp混编/">matlab cpp混编</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/QtStudy/Cpp中回调函数与静态成员/">Cpp中回调函数与静态成员</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/QtStudy/Qt中pro文件写法/">Qt pro文件写法</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/OpenSource/Qt串口开发QextserialPort/">Qt串口开发QextserialPort</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/QtStudy/Qt常见错误汇总/">Qt 常见错误汇总</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/OpenSource/Qt绘图库QCustomplot/">Qt绘图库 QCustomPlot</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/OpenSource/cpp机器人库robot-library/">cpp机器人库robot-library</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/OpenSource/开源库大全/">开源库大全</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/Python/Python-入门学习（二）/">Python-入门学习（二）</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/Python/Python-入门学习（一）/">Python-入门学习（一）</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/QtStudy/Qt中界面类名的修改/">Qt ui界面调用</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/Hexo/HEXO-Github-快速搭建属于自己的博客/">HEXO+Github Create your Blog</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/Journal/hello-world/">Hello World</a></li></ul>




    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                <i class="fa fa-copyright"></i> 
                2016-2017 Mark
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank" title="A fast, simple &amp; powerful blog framework">Hexo</a>  Theme <a href="https://github.com/MOxFIVE/hexo-theme-yelee" target="_blank" title="Another simple and elegant theme for Hexo  v3.5">Yelee</a> by MOxFIVE <i class="fa fa-heart animated infinite pulse"></i>
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" title="Site Visitors"><i class="fa fa-user" aria-hidden="true"></i><span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>| </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit"  title="Page Hits"><i class="fa fa-eye animated infinite pulse" aria-hidden="true"></i><span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>
    </div>
    
<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>

    <script>
        $(document).ready(function() {
            var iPad = window.navigator.userAgent.indexOf('iPad');
            if (iPad > -1 || $(".left-col").css("display") === "none") {
                var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
                var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
                $("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
            }
            else {
                var backgroundnum = 27;
                var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
                $("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
            }
        })
    </script>





    <script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script src="//cdn.bootcss.com/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


<div class="scroll" id="scroll">
    <a href="#" title="Back to Top"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" onclick="load$hide();" title="Comments"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="Go to Bottom"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    // Open in New Window
    
        var oOpenInNew = {
            
            
            
            
            
            
             archives: ".archive-article-title", 
             miniArchives: "a.post-list-link", 
            
             friends: "#js-friends a", 
             socail: ".social a" 
        }
        for (var x in oOpenInNew) {
            $(oOpenInNew[x]).attr("target", "_blank");
        }
    
</script>

    <script>
        var originTitle = document.title;
        var titleTime;
        document.addEventListener("visibilitychange", function() {
            if (document.hidden) {
                document.title = "(つェ⊂) 我藏好了哦~ " + originTitle;
                clearTimeout(titleTime);
            }
            else {
                document.title = "(*´∇｀*) 被你发现啦~ " + originTitle;
                titleTime = setTimeout(function() {
                    document.title = originTitle;
                }, 2000);
            }
        })
    </script>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
  </div>
</body>
</html>